﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DLV.Utilities;

namespace DLV.Data.Entities
{
    public class CityController
    {
        public int InsertCity(CityInfo info)
        {
            return SQL.InsertCity(info.NationalId, info.CityName);
        }
        public void UpdateCity(CityInfo info)
        {
            SQL.UpdateCity(info.CityId, info.NationalId, info.CityName);
        }
        public void DeleteCity(CityInfo info)
        {
            DeleteCity(info.CityId);
        }
        public void DeleteCity(int cityId)
        {
            SQL.DeleteCity(cityId);
        }
        public CityInfo GetCity(int cityId)
        {
            return CBO.FillObject<CityInfo>(SQL.GetCity(cityId));
        }
        public List<CityInfo> ListCity()
        {
            return CBO.FillCollection<CityInfo>(SQL.ListCity());
        }
        public DataTable SelectCity()
        {
            return CBO.ConvertToDataTable(ListCity(), typeof(CityInfo));
        }
        public Dictionary<object, object> ListCityLookup()
        {
            var pages = ListCity();
            var dicpages = new Dictionary<object, object>();
            foreach (var info in pages)
                dicpages.Add(info.CityId, info.CityName);
            return dicpages;
        }
        public List<CityInfo> ListCityByNational(int countryId)
        {
            return CBO.FillCollection<CityInfo>(SQL.ListCityByNational(countryId));
        }
    }
}
